package com.sasis.webapp.task.ftp;

import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;



import junit.framework.TestCase;

public class FtpbkoTest extends TestCase {
	Ftpbko bko;
	public FtpbkoTest(String name) {
		super(name);
	}

	protected void setUp() throws Exception {
		super.setUp();
//		bko = new Ftpbko();
//		bko.setBeginSubTime(5);
//		bko.setEndSubTime(17);
//		bko.setBeginSubGzip(0);
//		bko.setEndSubGzip(21);
//		bko.setBeginSubFlagTime(7);
//		bko.setEndSubFlagTime(19);
//		bko.setMaxBKOFileLength(24);
//		bko.setMaxFlagFileLength(27);
//		bko.setPrefixBKOFile("ZHBKO");
//		bko.setPostfixBKOFile(".txt.gz");
//		bko.setPrefixFlagFile("zhbko");
//		bko.setPostfixFlagFile("flag.dat");
//		
////		   Class.forName("FtpClientBKOImpl").
//		   
//		   FtpClientBKOImpl ftpClient = new FtpClientBKOImpl();
//		   ftpClient.setHostAdress("219.134.185.10");
//		   ftpClient.setPassword("travelsky");
//		   ftpClient.setPort(21);
////		   ftpClient.setTimeout(600000);
//		   ftpClient.setUser("zhbko");
//		   ftpClient.setSocksAddress("10.123.74.137");
//		   ftpClient.setSocksPort(1080);
////		   ftpClient.setFtpClient(new FTPClient());
////		   ftpClient.setRemoteTransTagFileName("zhbko.flag");
//		  
//		   
//		bko.setFtpClient(ftpClient);
//		bko.setLocalPath("e:\\temp\\");
//		bko.setTagDate("070921214017");
//		bko.setCompressor(new GzipTools());
//		bko.setRemoteBackupPath("backup\\");
////		bko.execute();
//		
//		
////		bko.init();
		
	}
	protected void tearDown() throws Exception {
		super.tearDown();
		bko.closeFtp();
	}

	public void testGetRemoteAllFileList() {
		bko.getRemoteAllFileList();
	}

	public void testDownloadFromList() {
		bko.getRemoteAllFileList();
		bko.downloadFromList();
	}

	public void testMoveRemoteFiles(){
		boolean test = bko.moveRemoteFiles("ZHBKO070827154521.txt.gz");
		super.assertEquals(test, true);
	}
	
	public void testExcute() {
		
		Ftpbko.executeBko();
	}
	
	public void testDateFormat(){
		SimpleDateFormat hhmmFormatter2 = new SimpleDateFormat("MMM d yyyy");
		ParsePosition position = new ParsePosition(0);
		Date date = hhmmFormatter2.parse("Sep 20 2006",position);
		System.out.println(date);
		
//		UnixFTPEntryParser unix = new UnixFTPEntryParser();
//		try {
//			Calendar ca = unix.parseTimestamp("Sep 20 2006");
//			System.out.println(ca.getTime());
//		} catch (ParseException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
		
	}
	
}
